﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- Line Button -->
    <Style x:Key="ChromeLineButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Name="Border"
                            Background="WhiteSmoke"
                            BorderBrush="WhiteSmoke">
                        <Path Name="Path"
                              HorizontalAlignment="Center"
                              VerticalAlignment="Center"
                              Fill="Gray"
                              Data="{Binding Path=Content,RelativeSource={RelativeSource TemplatedParent}}" />
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{StaticResource ButtonHotTrackForegroundBrush}" />
                        </Trigger>
                        <Trigger Property="IsPressed" Value="true">
                            <Setter TargetName="Path" Property="Fill" Value="{StaticResource ButtonPressedBackgroundBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Page Button -->
    <Style x:Key="ChromePageButtonStyle" TargetType="{x:Type RepeatButton}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type RepeatButton}">
                    <Border Background="WhiteSmoke" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Thumb Button -->
    <Style x:Key="ChromeThumbButtonStyle" TargetType="{x:Type Thumb}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Setter Property="IsTabStop" Value="false"/>
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Name="Border"
                            Background="LightGray"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="1">
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver"  Value="true">
                            <Setter TargetName="Border" Property="Background" Value="DarkGray" />
                        </Trigger>
                        <Trigger Property="IsDragging"  Value="true">
                            <Setter TargetName="Border" Property="Background" Value="Gray" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- Vertical Scroll Bar-->
    <ControlTemplate x:Key="ChromeVerticalScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="18" />
                <RowDefinition />
                <RowDefinition Height="18" />
            </Grid.RowDefinitions>
                       
            <Border Grid.RowSpan="3"
                    Background="WhiteSmoke" />
            
            <RepeatButton Grid.Row="0"
                          Style="{StaticResource ChromeLineButtonStyle}"
                          Command="ScrollBar.LineUpCommand"
                          Content="M 0 4 L 8 4 L 4 0 Z" />
                
            <Track Name="PART_Track"
                   IsDirectionReversed="true"
                   Grid.Row="1"
                   Margin="2,0,2,0">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Style="{StaticResource ChromePageButtonStyle}"
                                  Command="ScrollBar.PageUpCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Style="{StaticResource ChromeThumbButtonStyle}" 
                           Margin="0,1,0,1"
                           Background="DarkGray"
                           BorderBrush="Gray" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Style="{StaticResource ChromePageButtonStyle}"
                                  Command="ScrollBar.PageDownCommand" />
                </Track.IncreaseRepeatButton>
            </Track>

            <RepeatButton Grid.Row="3"
                          Style="{StaticResource ChromeLineButtonStyle}"
                          Command="ScrollBar.LineDownCommand"
                          Content="M 0 0 L 4 4 L 8 0 Z" />
            
        </Grid>
    </ControlTemplate>

    <!-- Horizontal Scroll Bar -->
    <ControlTemplate x:Key="ChromeHorizontalScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Grid >
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="18" />
                <ColumnDefinition />
                <ColumnDefinition Width="18" />
            </Grid.ColumnDefinitions>

            <Border Grid.ColumnSpan="3"
                    Background="WhiteSmoke" />

            <RepeatButton Grid.Column="0"
                          Style="{StaticResource ChromeLineButtonStyle}"
                          Command="ScrollBar.LineLeftCommand"
                          Content="M 4 0 L 4 8 L 0 4 Z" />

            <Track Name="PART_Track"
                   IsDirectionReversed="False"
                   Grid.Column="1"
                   Margin="0,2,0,2">
                <Track.DecreaseRepeatButton>
                    <RepeatButton Style="{StaticResource ChromePageButtonStyle}"
                                  Command="ScrollBar.LineLeftCommand" />
                </Track.DecreaseRepeatButton>
                <Track.Thumb>
                    <Thumb Style="{StaticResource ChromeThumbButtonStyle}" 
                           Margin="1,0,1,0"
                           Background="DarkGray"
                           BorderBrush="Gray" />
                </Track.Thumb>
                <Track.IncreaseRepeatButton>
                    <RepeatButton Style="{StaticResource ChromePageButtonStyle}"
                                  Command="ScrollBar.LineRightCommand" />
                </Track.IncreaseRepeatButton>
            </Track>

            <RepeatButton Grid.Column="2"
                          Style="{StaticResource ChromeLineButtonStyle}"
                          Command="ScrollBar.LineRightCommand"
                          Content="M 0 0 L 4 4 L 0 8 Z" />
        </Grid>
    </ControlTemplate>

    <!-- Scroll Bar -->
    <Style x:Key="ChromeScrollBarStyle" TargetType="{x:Type ScrollBar}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="OverridesDefaultStyle" Value="true"/>
        <Style.Triggers>
            <Trigger Property="Orientation" Value="Horizontal">
                <Setter Property="Width" Value="Auto"/>
                <Setter Property="Height" Value="18" />
                <Setter Property="Template" Value="{StaticResource ChromeHorizontalScrollBarStyle}" />
            </Trigger>
            <Trigger Property="Orientation" Value="Vertical">
                <Setter Property="Width" Value="18"/>
                <Setter Property="Height" Value="Auto" />
                <Setter Property="Template" Value="{StaticResource ChromeVerticalScrollBarStyle}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <!-- Scroll Viewer -->
    <Style x:Key="ChromeScrollViewerStyle" TargetType="{x:Type ScrollViewer}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>

                        <ScrollContentPresenter Grid.Row="0"
                                                Grid.Column="0"/>

                        <ScrollBar Name="PART_VerticalScrollBar"
                                   Style="{StaticResource ChromeScrollBarStyle}"
                                   Orientation="Vertical"
                                   Grid.Row="0"
                                   Grid.Column="1"
                                   Value="{TemplateBinding VerticalOffset}"
                                   Maximum="{TemplateBinding ScrollableHeight}"
                                   ViewportSize="{TemplateBinding ViewportHeight}"
                                   Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}"/>

                        <ScrollBar Name="PART_HorizontalScrollBar"
                                   Style="{StaticResource ChromeScrollBarStyle}"
                                   Orientation="Horizontal"
                                   Grid.Row="1"
                                   Grid.Column="0"
                                   Value="{TemplateBinding HorizontalOffset}"
                                   Maximum="{TemplateBinding ScrollableWidth}"
                                   ViewportSize="{TemplateBinding ViewportWidth}"
                                   Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}"/>

                        <Border Background="WhiteSmoke"
                                Grid.Row="1"
                                Grid.Column="1" />

                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>